package org.hackystat.app.projectstatus.alert;

import org.hackystat.core.kernel.admin.ServerProperties;
import org.hackystat.core.kernel.user.User;
import org.hackystat.core.kernel.util.Day;

/**
 * Implements an Alert singleton.
 * 
 * @author Josh
 *
 */
public class ProjectStatusWeeklyAlert {

  /** Creates the singleon Alert instance.  */
  public ProjectStatusWeeklyAlert() { }


  /**
   * Returns true if this alert is enabled by this user and if any sensor data
   * exists for this user for the day prior to the passed day.
   *
   * @param user  The user of interest.
   * @param day   The day of interest.
   * @return      True if this alert is enabled and sensor data exists, false
   *      otherwise.
   */
  public boolean isTriggered(User user, Day day) {
    return false;
  }


  /**
   * Returns a string containing a one line explanation for why the event was
   * triggered.
   *
   * @param user  The user of interest.
   * @param day   The day of interest.
   * @return      The triggerExplanation value.
   */
  public String getTriggerExplanation(User user, Day day) {
    return "Sends an email indicating the daily project details of the project designated";
  }


  /**
   * Returns an URL that will invoke a command to display SensorData summary
   * statistics on the day prior to the passed day. This provides details on
   * exactly what data was received that led to the triggering of this alert.
   *
   * @param user  The user of interest.
   * @param day   The day of interest.
   * @return      The displayUrl value.
   */
  public String getDisplayUrl(User user, Day day) {
    Day yesterday = day.inc(-1);
    return ServerProperties.getInstance().getHackystatHome()
           + "controller"
           + "?Key=" + user.getUserKey()
           + "&Command=" + "ProjectStatus"
           + "&StartDay=" + yesterday.getDayString()
           + "&StartMonth=" + yesterday.getMonthString()
           + "&StartYear=" + yesterday.getYearString();
  }


  /**
   * Returns true if NewDataAlert is enabled by default.
   *
   * @param user  The user of interest.
   * @return      True.
   */
  public boolean isEnabledByDefault(User user) {
    return false;
  }

}
